/**
 * 本地缓存
 */

/**
 * 获取
 * @param {*} key 
 */
export const getStorageItem = key => {
	try {
		const val = uni.getStorageSync(key)
		try {
			return JSON.parse(val)
		} catch (error) {
			return val
		}
	} catch (error) {
		return null
	}
}

/**
 * 设置
 * @param {*} key 
 * @param {*} val 
 */
export const setStorageItem = (key, val) => {
  if (typeof val === 'object') {
    val = JSON.stringify(val)
	}
	try {
		uni.setStorageSync(key, val)
	} catch (error) {
		throw error
	}
}

/**
 * 删除
 * @param {*} key 
 */
export const removeStorageItem = key => {
	try {
		uni.removeStorageSync(key)
	} catch (error) {
		throw error
	}
}